#include<bits/stdc++.h>
using namespace std;
int josephus(int n, int k) {
    int res = 0;
    for (int i = 1; i <= k; ++i)
      res = (res + 2) % (n+1);
    return res + 1;
}
int main() {
  cout<<josephus(1337, 1313)<<endl;
}
